<?php

/**
 * Contains site-wide configuration directives.
 *
 * All configuration of this site is located in this file (site name, 
 * filepaths, addresses, contact information, etc), the CSS files (site 
 * visual layout), and the database (categories, users, etc).
 *
 * PHP Version 5
 *
 * @category BuyLocal
 * @package  BuyLocal
 * @author   Alexander Adami <adamia@rpi.edu>
 * @author   Kevin Fodness <kevin.fodness@gmail.com>
 * @author   Mike Pennisi <mpennisi@andrew.cmu.edu>
 * @author   Aaron Ryden <aryden@gmail.com>
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
 * @link     http://code.google.com/p/buylocalopensourcerensselaer/
 */

/**
 * Required Configuration Section.
 *
 * The contents of this section MUST be localized for the specific
 * installation of this software before it can be used.
 */
 
/** Sets the default timezone. */
date_default_timezone_set('America/New_York');

/** The base URL for the site. */
define('BASE_URL', 'http://www.example.com');

/**
 * The relative path (BASE_URL minus the hostname).  Must end in a /
 *
 * @internal / or /path/to/www/
 * @internal IMPORTANT: If this value is anything OTHER than /, you will need
 *           to modify the relative paths of images within the main.css file,
 *           located at /www/stylesheets.  Paths must be changed from /images
 *           to whatever you put here + /images.  For example:
 *           /path/to/www/images/header.jpg
 */
define('RELATIVE_PATH', '/');

/** The full root include path (the path to the 'src' directory). */
define('INCLUDE_PATH', '/path/to/src');

/** The full path to the error log file. */
define('ERRORLOG', '/path/to/log/errors.txt');

/** The textual site name. */
define('SITENAME', 'Buy Local');

/** * The default zip code for an unregistered user. */
define('D_ZIP', '12180');

/** Default unit of measurement for distance, either 'km' or 'mi'. */
define('D_DISTANCE', 'mi');

/** The return (from) address for system generated emails. */
define('RETURN_ADDRESS', 'noreply@example.com');

/** The database server name. */
define('DBSERVER', 'localhost');

/** The name of the database to use. */
define('DBNAME', 'exampledb');

/** The username to connect to the database. */
define('DBUSER', 'exampleuser');

/** The password to connect to the database. */
define('DBPASS', 'examplepass');

/** Installation passphrase. Required in order to use install.php. */
define('INSTALL_PASSWORD', '');
 
/**
 * The database engine to use.
 *
 * @internal This value corresponds to a subdirectory under /src/database
 * which contains the database classes, SQL files, etc specific to that
 * database engine.  Examples include 'mysqli', 'mssql', 'oracle', etc.
 * Ensure that the subdirectory exists before using a value.  It is possible
 * that the library for the specific database server you would like to use
 * has not yet been written.  Check the source code repository at 
 * http://code.google.com/p/buylocalopensourcerensselaer/
 * to see if updated libraries have been written for your database engine
 * of choice.  You can also write custom database engine code, place it
 * in a subdirectory of your choosing, and call it from here.
 * Attention mySQL users: if mysqli is available on your PHP distro, use it.
 * If not, you can fall back to the legacy mysql engine.
 */ 
define('DBENGINE', 'mysqli');

/**
 * Expert Configuration Section.
 *
 * The contents of this section should not need to be modified for a default
 * installation.  Modify at your own risk.
 */
 
/**
 * Sets the include path based on the configuration values specified above.
 */
$includePath  = ini_get('include_path');
$includePath .= ':' . INCLUDE_PATH . ':'
    . INCLUDE_PATH . '/classes:'
    . INCLUDE_PATH . '/database/' . DBENGINE . ':'
    . INCLUDE_PATH . '/functions';
ini_set('include_path', $includePath);

/** @uses __autoload For automatically including classes later. */
require_once 'function_autoload.php';

/** @uses errorHandler For custom error handling. */
require_once 'function_errorhandler.php';

/** @uses sanitizeSuperglobals To sanitize user input. */
require_once 'function_sanitizesuperglobals.php';

/** @uses valueOf For safe handling of arrays. */
require_once 'function_valueof.php';

/**
 * Error handling configuration.
 *
 * Error handling is controlled by a custom error handling function.  See
 * that function for specifics on how errors are handled.
 */
set_error_handler('errorHandler', E_ALL | E_STRICT);

/** The UNIX epoch. */
define('EPOCH', valueOf(getdate(), 0));

/** The current year. */
define('YEAR', valueOf(getdate(), 'year'));

/** The date and time format. */
define('DATEFORMAT', 'F d, Y');

/** The session length, in seconds. */
define('SESSIONLENGTH', 3600);

/** Role constant for a guest. */
define('R_GUEST', 0);

/** Role constant for a registered user. */
define('R_USER', 1);

/** Role constant for a store owner. */
define('R_OWNER', 2);

/** Role constant for an administrator. */
define('R_ADMIN', 3);

/** Length constant for an email address. */
define('L_EMAIL', 320);

/** Length constant for a password. */
define('L_PASSWORD', 128);

/** Length constant for a zip code. */
define('L_ZIP', 10);

/** Length constant for a person's name. */
define('L_NAME', 50);

/** Length constant for a phone number. */
define('L_PHONE', 15);

/** Length constant for a fax number. */
define('L_FAX', 15);

/** Length constant for contact information descriptions. */
define('L_CONTACTDESC', 25);

/** Length constant for a store's name. */
define('L_STORENAME', 100);

/** Length constant for a store's street address. */
define('L_STOREADDR', 100);

/** The number of stores to display per page. */
define('STORES_PER_PAGE', 10);

/** The number of events to display per page. */
define('EVENTS_PER_PAGE', 10);

/** The number of users to display per page (administrators). */
define('USERS_PER_PAGE', 10);

/** The search radius options separated by commas with no spaces. */
define('SEARCH_RADIUS', '25,50,100,250,500');

/** The path to the Google Maps API v3 script. No API key is required. */
define('GM_URL', 'http://maps.google.com/maps/api/js?sensor=false');

/** The Google Maps API Key. Leave this as '' unless you're getting errors. */
define('GM_API_KEY', '');

/**
 * The path to the Google Maps API Geocoding service.
 *
 * An API Key does not seem to be required at the moment (Oct 2009), but the API 
 * spec says it is.
 */
define(
    'GM_GEOCODE_URL',
    'http://maps.google.com/maps/geo?output=xml&sensor=false&key=' . GM_API_KEY
);
 
/** The private key for the reCAPTCHA library. */
define('RECAPTCHA_PRIV_KEY', '6Lfl-gkAAAAAABdv_6uUvo3cAtsCrPCJjtvFE5c8');

/** The public key for the reCAPTCHA library. */
define('RECAPTCHA_PUB_KEY', '6Lfl-gkAAAAAAFMhntrLYKA4gFjCBl06KX4kbBZE');

/** Stores the current page URL. */
define(
    'PAGE_URL',
    'http://' . $_SERVER['HTTP_HOST'] . valueOf($_SERVER, 'REQUEST_URI')
);

/**
 * Ensures that the hosting location and the location specified in the
 * BASE_URL directive are the same.  Redirects if not.
 */
if (substr(PAGE_URL, 0, strlen(BASE_URL)) != BASE_URL) {
    header('Location: ' . BASE_URL);
}

/** Runs the sanitizeSuperglobals function recursively on $_POST, $_GET, $_COOKIE. */
sanitizeSuperglobals($_POST);
sanitizeSuperglobals($_GET);
sanitizeSuperglobals($_COOKIE);

?>